/*
 * Copyright (C) 2019-2020 Alibaba Group Holding Limited
 */
#include <stdlib.h>
#include <string.h>
#include <aos/list.h>
#include <aos/debug.h>

#include <uservice/uservice.h>
#include <uservice/eventid.h>
#include <yoc/sysinfo.h>
#include <board.h>

//#include <ntp.h>
#include <time.h>

#include "app_player.h"
#include "app_main.h"
#include "app_rtc.h"
#include "app_oled.h"
#include "app_display.h"
#include "app_rgb.h"
#include "app_key.h"
#include "app_iot.h"
#include "app_weather.h"

#define TAG "APP"

#if (NTP_DEBUG == STD_ON)
static void task1_entry(void *arg);
#endif
static void network_event(uint32_t event_id, const void *param, void *context);

int main(void)
{
    board_yoc_init();

    /* Subscribe */
    event_subscribe(EVENT_NETMGR_GOT_IP, network_event, NULL);
    event_subscribe(EVENT_NETMGR_NET_DISCON, network_event, NULL);
    
    Rtc_Init();
	Alarm_TaskInit();
	Disp_Init();
	Rgb_TaskInit();
	Key_TaskInit();
#if (PLAYER_ENABLE == STD_ON)
	Player_TaskInit();
#endif
	Weather_TaskInit();
    Iot_Init();
}

static void network_event(uint32_t event_id, const void *param, void *context)
{
    switch(event_id) {
    case EVENT_NETMGR_GOT_IP:
        LOGD(TAG, "net got ip");
        break;
    case EVENT_NETMGR_NET_DISCON:
        LOGD(TAG, "net disconnect");
        break;
    }

    /*do exception process */
    app_exception_event(event_id);
}

